package com.api.shopapi.service.impl;

import com.api.shopapi.entity.CardRecord;
import com.api.shopapi.entity.dto.CardRecordDTO;
import com.api.shopapi.mapper.CardRecordMapper;
import com.api.shopapi.service.CardRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("CardRecordServiceImplOne")
public class CardRecordServiceImpl implements CardRecordService {

    @Autowired
    CardRecordMapper cardRecordMapper;

    @Override
    public int insert(CardRecord cardRecord) {
        return cardRecordMapper.insert(cardRecord);
    }

    @Override
    public PageInfo<CardRecordDTO> getPage(int pageIndex, int pageSize, String governmentCode, String cardNumber, String name) {
        PageHelper.startPage(pageIndex,pageSize);
        List<CardRecordDTO> cardRecordDTOList = cardRecordMapper.getPage(governmentCode, cardNumber, name);
        return new PageInfo<>(cardRecordDTOList);
    }
}
